<?php
	require_once 'Connect.class.php';
	require_once 'DanhMuc.class.php';
	/**
	* 
	*/
class TinhTrangGV extends DanhMuc
{
	
	public	function __construct()
	{
		
	}
	public function getInfo($maTTGV){

			$conn= new Connect();

			$conn->Query("SELECT * FROM tbl_tinhtrang_giangvien WHERE maTTGV='".$maTTGV."'; ");	

			while ($row=$conn->Fetch()) {	

				$this->ma=$row['maTTGV'];
				$this->ten=$row['tenTTGV'];
			}
			// dong ket noi
			$conn->close();
	}
	public function checkNo($maTTGV){

			$rs=false;

			$conn= new Connect();

			$conn->Query("SELECT COUNT(maTTGV) as dem FROM tbl_tinhtrang_giangvien WHERE maTTGV='".$maTTGV."'; ");	

			while ($row=$conn->Fetch()) {	
				if ($row['dem']==1){
					$rs=true;
				}
			}
			// dong ket noi
			$conn->close();
			return $rs;
		}
	public function ds(){
			$ds=array();
			$conn= new Connect();
			$conn->Query("SELECT * FROM tbl_tinhtrang_giangvien");
			$index=0;
			while ($row=$conn->Fetch()) {
				$tt= new TinhTrangGV();
				$tt->setMa($row['maTTGV']);
				$tt->setTen($row['tenTTGV']);
				$ds[$index]=$tt;
				$index++;
			}
			$conn->close();
			return $ds;
	}
		
	public function them(){

			$sql="INSERT INTO tbl_tinhtrang_giangvien(maTTGV,tenTTGV) values('".$this->ma."','".$this->ten."')";

			$conn=new Connect();

			$conn->Query($sql);

			$conn->close();
			
	}
	public function xoa(){
			$sql="DELETE FROM tbl_tinhtrang_giangvien WHERE maTTGV='".$this->ma."'";

			$conn=new Connect();

			$conn->Query($sql);

			$conn->close();

		}
	public function capnhat(){
		
			$sql="UPDATE tbl_tinhtrang_giangvien SET tenTTGV='".$this->ten."' WHERE maTTGV='".$this->ma."'";

			$conn=new Connect();

			$conn->Query($sql);

			$conn->close();
		}

	}
?>